# -*- coding: utf-8 -*-
#
# Copyright (C) 2011  Benjamin Heil
#
# This file is part of Feedmail.
#
# Feedmail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
import sys

from django.test.simple import DjangoTestSuiteRunner

os_path = os.path.abspath(__file__)
root_path = os.path.join(os.path.split(os.path.split(os_path)[0])[0], 'cron')
sys.path.append(root_path)

class FeedMailTestSuiteRunner(DjangoTestSuiteRunner):

    def run_tests(self, test_labels, *args, **kwargs):
        """ 
        Only run tests for our local applications, not the django tests.
        http://groups.google.com/group/django-developers/msg/ec7508651e9e9fb8?pli=1
        """
        from django.conf import settings
        from feedmail_cron_test import TestFeedmailCron
        t = TestFeedmailCron()
        extra_tests = [t]
        return super(FeedMailTestSuiteRunner, self).run_tests(test_labels=settings.FEEDMAIL_APPS, extra_tests=extra_tests, *args, **kwargs)
